/**
 * License would add here
 */

#include "macros.h"

NAPI_UTILS_EXTERN const char* ReadNapiStatus(napi_status status)
{
#define CASE(status) \
    case status:     \
        return #status

    switch (status) {
        CASE(napi_ok);
        CASE(napi_invalid_arg);
        CASE(napi_object_expected);
        CASE(napi_string_expected);
        CASE(napi_name_expected);
        CASE(napi_function_expected);
        CASE(napi_number_expected);
        CASE(napi_boolean_expected);
        CASE(napi_array_expected);
        CASE(napi_generic_failure);
        CASE(napi_pending_exception);
        CASE(napi_escape_called_twice);
        CASE(napi_handle_scope_mismatch);
        CASE(napi_callback_scope_mismatch);
        CASE(napi_closing);
        CASE(napi_queue_full);
        CASE(napi_bigint_expected);
        CASE(napi_date_expected);
        CASE(napi_arraybuffer_expected);
        CASE(napi_detachable_arraybuffer_expected);
#ifdef OHOS_PLATFORM
        CASE(napi_no_external_buffers_allowed);
        CASE(napi_cannot_run_js);
#endif
    default:
        return "unknown";
        break;
    }
#undef CASE
}

NAPI_UTILS_EXTERN const char* ReadNapiType(napi_valuetype type)
{
#define CASE(type) \
    case type:     \
        return #type

    switch (type) {
        CASE(napi_undefined);
        CASE(napi_null);
        CASE(napi_boolean);
        CASE(napi_number);
        CASE(napi_string);
        CASE(napi_symbol);
        CASE(napi_object);
        CASE(napi_function);
        CASE(napi_external);
        CASE(napi_bigint);
    default:
        return "unknown";
        break;
    }
#undef CASE
}